package com.acv.libs.nbase;

import z.lib.base.BaseAnimationUtils.AnimationAction;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.knock.app.R;

public abstract class Base3Activity extends FragmentActivity {
	private FrameLayout mFrameLayout;

	// private FacebookUtils facebookUtils;
	// private TwitterJS twitterJS;
	@Override
	public void finish() {
		super.finish();
		overridePendingTransition(0, R.anim.scale_to_center);//
	}

	@Override
	public void startActivityForResult(Intent intent, int requestCode) {
		super.startActivityForResult(intent, requestCode);
	}

	@Override
	public void startActivity(Intent intent) {
	}

	public void refresh() {

	}

	public void refreshMenu() {
	}

	public void clearMenu() {
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		
		setContentView(R.layout.base);
		overridePendingTransition(R.anim.scale, R.anim.a_nothing);//

		mFrameLayout = (FrameLayout) findViewById(R.id.mFrament);
	}

	public void enableMenuLeft() {
	}

	public void setTextheader(int str) {}

	public void setTextheader(String str) {}

	
	/**
	 * add fragment
	 * 
	 */

	private BaseFragment currBaseFragment;
	private Handler handler = new Handler();

	public void changeFragemt(final BaseFragment rFragment) {
		// handler.postDelayed(new Runnable() {
		//
		// @Override
		// public void run() {
		overridePendingTransition(R.anim.scale, R.anim.a_nothing);
		
		rFragment.setMParentFragment(currBaseFragment);
		currBaseFragment = rFragment;
		FragmentManager fragmentManager = getSupportFragmentManager();
		FragmentTransaction ft = fragmentManager.beginTransaction();
		ft.replace(R.id.main_content, rFragment);
		ft.commit();

		// }
		// }, MenuSlideView.TIMECALLMENU);

	}

	/*
	 * MENU LEFT
	 */
	public void onItemClickmenuLeft(AdapterView<?> parent, View view, int position, long id) {

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
		super.onActivityResult(requestCode, resultCode, intent);
	}

	public abstract void configMenuleft();

	public void addmenu(MenuItem item) {}

	public void showMenuLeft(boolean show) {}

	public void showMenuSubRight(boolean show) {}

	public void configMenuRight() {}

	public void showMenuRight(boolean show) {}

	

	public void setChoosePosition(int i) {
		if (currBaseFragment != null) {
			currBaseFragment.setChoosePosition(i);
		}
	}

	public void openFragmentListener(View mMain, final AnimationAction animationAction) {
		if (mMain == null)
			return;
		Animation animation = AnimationUtils.loadAnimation(this, R.anim.a_nothing);
		animation.setAnimationListener(new AnimationListener() {

			@Override
			public void onAnimationStart(Animation animation) {

			}

			@Override
			public void onAnimationRepeat(Animation animation) {

			}

			@Override
			public void onAnimationEnd(Animation animation) {
				if (animationAction != null)
					animationAction.onAnimationEnd();
			}
		});
		mMain.startAnimation(animation);
	}
}